#!/bin/bash 
set -e

TMP=${TMP:-/tmp/work}
LOG=${LOG:-$HOME/logs/stage3}
SRC=${SRC:-/sources}

name=elfutils
version=0.183

rm -rf $TMP
mkdir -p $TMP $LOG

tar xf $SRC/$name-$version.tar.bz2 -C $TMP

{ time \
   {

    cd $TMP/$name-$version
    
	./configure --prefix=/usr                \
				--disable-debuginfod         \
				--enable-libdebuginfod=dummy \
				--libdir=/lib
    
    make
    
	make -C libelf install
	install -vm644 config/libelf.pc /usr/lib/pkgconfig
	rm /lib/libelf.a

    }
} 2>&1 | tee $name.log
    
[ $PIPESTATUS = 0 ] && mv $name.log $LOG || exit $PIPESTATUS

rm -fr $TMP
